<template>
  <div>
    <el-button type="primary" @click="handleAdd">新增</el-button>

    <el-table ref="deviceTable" v-loading="loading" :data="alarmRecordingList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="告警名称" align="center" prop="deviceName"/>
      <el-table-column label="创建时间" sortable align="center" prop="registryTime"/>
      <el-table-column label="运行状态" align="center" prop="startState">
        <template slot-scope="scope">
          <el-switch
            v-model="scope.row.startState"
            active-value="enabled"
            inactive-value="disabled"
            @change="handleUpdate(scope.row)"
          ></el-switch>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            v-if="scope.row.deviceState === 'notActive'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['iot:protocol:edit']"
          >编辑
          </el-button>
          <el-button
            v-if="scope.row.deviceState === 'notActive'"
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['iot:protocol:remove']"
          >删除
          </el-button>
          <el-button
            v-if="scope.row.deviceState === 'notActive'"
            size="mini"
            type="text"
            icon="el-icon-open"
            @click="handleEnableDisableStateChange(scope.row)"
            v-hasPermi="['iot:protocol:remove']"
          >启用
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <alarm-recording-add-edit ref="alarmRecordingAddEdit"/>
  </div>
</template>

<script>
import {mapState} from 'vuex'
//告警管理
import AlarmRecordingAddEdit from '@/views/iot/device/alarm/particulars/alarmRecordingAddEdit'

export default {
  name: 'AlarmRecording',
  data() {
    return {
      // 告警设置表格数据
      alarmRecordingList: [],
      // 遮罩层
      loading: false,
    }
  },
  components: {
    AlarmRecordingAddEdit
  },
  computed: {
  },
  methods: {
    resetQuery() {

    },
    handleEnableDisableStateChange() {

    },
    handleDelete() {

    },
    handleAdd() {
      this.$refs.alarmRecordingAddEdit.handleAdd();
    },
    handleUpdate() {
      this.$refs.alarmRecordingAddEdit.handleAdd();
    },
    handleSelectionChange() {

    }
  }
}
</script>

<style scoped>
  .view {
    position: absolute;
    top: 7px;
    left: 200px;
  }
</style>
